var http = require('http');

var url = require('url');
var router = require('./router');
var wFile = require('./modules/wFile');
http.createServer(function (request,response){
    if(request.url !== "/favicon.ico")
    {
        pathname = url.parse(request.url).pathname;
        pathname = pathname.replace(/\//,'');
        try{
            router[pathname](request,response);
        }catch(err){
            console.log('出错了'+err);
            response.writeHead(200,{'Content-Type':'text/html;charset=utf-8'});
            response.write(err.toString());
            response.end('');
        }
        
    }
}).listen(8000);
console.log('Server running at port http://localhost:8000');